package com.mini.cn.goods.service;

import com.mini.cn.goods.exception.MiniGoodsException;
import com.mini.cn.goods.po.GoodsInfo;
import com.mini.cn.goods.po.UserModel;
import com.mini.cn.goods.po.dto.GroupDesDto;
import com.mini.cn.goods.util.ErrorMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: fly
 * Date: 2022/11/19
 * Time: 18:04
 */
@Service("GroupGoodsService")
public class GroupGoodsService extends BaseService {

    @Autowired
    UserService userService;

    public GroupDesDto getAllGroupGoods(int appid, String openid) {
        try {
            UserModel userModel= userService.findUserByOpenId(openid,appid);
            GroupDesDto groupDesDto=new GroupDesDto();
            List<GoodsInfo> goodsInfos = goodsInfoDao.findAllUseGoodsList(appid);
            groupDesDto.setGoods(goodsInfos);
            return groupDesDto;
        } catch (Exception e) {
            throw new MiniGoodsException(String.valueOf(ErrorMsg.STATUS_GROUPSALE_ERROR), ErrorMsg.MSG_GROUPSALE_ERROR);
        }
    }
}
